package demoMod.stsconsole.dungeons;

import demoMod.stsconsole.events.AbstractEvent;
import demoMod.stsconsole.events.exordium.GoopWorld;
import demoMod.stsconsole.events.exordium.Mushrooms;
import demoMod.stsconsole.rooms.AbstractRoom;

import java.util.ArrayList;
import java.util.List;

public class Exordium extends AbstractDungeon {
    public static final String ID = "Exordium";

    public Exordium() {
        this.dungeonId = ID;
    }

    @Override
    public float getActNum() {
        return 1;
    }

    @Override
    protected List<String> getWeakEnemyPool() {
        List<String> ret = new ArrayList<>();
        ret.add("JawWorm");
        ret.add("2 Slime_1");
        ret.add("2 Slime_2");
        ret.add("2 Louse_1");
        ret.add("2 Louse_2");
        ret.add("2 Louse_3");
        ret.add("Cultist");
        return ret;
    }

    @Override
    protected List<String> getStrongEnemyPool() {
        List<String> ret = new ArrayList<>();
        ret.add("AcidSlime_L");
        ret.add("SpikeSlime_L");
        ret.add("Lots of slimes");
        ret.add("JawWorm with slime_1");
        ret.add("JawWorm with slime_2");
        ret.add("Cultist with slime_1");
        ret.add("Cultist with slime_2");
        ret.add("3 Louse_1");
        ret.add("3 Louse_2");
        return ret;
    }

    @Override
    protected List<String> getEliteEnemyPool() {
        List<String> ret = new ArrayList<>();
        ret.add("Lagavulin");
        ret.add("GremlinNob");
        ret.add("3 Sentries");
        return ret;
    }

    @Override
    protected List<String> getBossPool() {
        List<String> ret = new ArrayList<>();
        ret.add("SlimeBoss");
        ret.add("Hexaghost");
        ret.add("TheGuardian");
        return ret;
    }

    @Override
    protected List<Class<? extends AbstractEvent>> getEventPool() {
        List<Class<? extends AbstractEvent>> ret = new ArrayList<>();
        ret.add(GoopWorld.class);
        ret.add(Mushrooms.class);
        return ret;
    }

    @Override
    public String getEncounter(AbstractRoom currRoom) {
        String encounterId;
        if (!currRoom.getRoomSymbol().equals("E")) {
            if ("B".equals(currRoom.getRoomSymbol())) {
                encounterId = getBoss();
                consumeBossKey();
            } else {
                if (weakEnemyCtr < 3) {
                    encounterId = this.weakEnemyPool.get(monsterRng.nextInt(this.weakEnemyPool.size()));
                    String[] tmp = encounterId.split("_");
                    while (tmp[0].equals(this.lastWeakEnemyEncounter.split("_")[0])) {
                        encounterId = this.weakEnemyPool.get(monsterRng.nextInt(this.weakEnemyPool.size()));
                        tmp = encounterId.split("_");
                    }
                } else {
                    encounterId = this.strongEnemyPool.get(monsterRng.nextInt(this.strongEnemyPool.size()));
                    String[] tmp = encounterId.split("_");
                    while (tmp[0].equals(this.lastStrongEnemyEncounter.split("_")[0])) {
                        encounterId = this.strongEnemyPool.get(monsterRng.nextInt(this.strongEnemyPool.size()));
                        tmp = encounterId.split("_");
                    }
                }
            }
        } else {
            encounterId = this.eliteEnemyPool.get(monsterRng.nextInt(this.eliteEnemyPool.size()));
            String[] tmp = encounterId.split("_");
            while (tmp[0].equals(this.lastEliteEnemyEncounter.split("_")[0])) {
                encounterId = this.eliteEnemyPool.get(monsterRng.nextInt(this.eliteEnemyPool.size()));
                tmp = encounterId.split("_");
            }
        }
        return encounterId;
    }
}
